Fk:loadTranslationTable{
  ["luming"] = "鹿鸣",
  ["lm"] = "鹿鸣",
  ["lm_k__wang"] = "王道",
  ["lm_k__wo"] = "我道",
  ["lm_k__ba"] = "霸道",
  ["lm_k__ge"] = "割据",
}
--[[
王道：刘备，袁绍，刘宏
我道：张角，吕布，董卓
霸道：曹操，曹丕，孙策
割据：孙权，马腾，严白虎
]]
local king = require("packages.luming.pkg_king")
local idolatry = require("packages.luming.pkg_idolatry")
local hegemon = require("packages.luming.pkg_hegemon")
local division = require("packages.luming.pkg_division")

--------------------------------------------新的DIY卡牌分割线-------------------------------------------------------
--替换原卡
local extension_card = Package:new("luming_cards", Package.CardPack)
extension_card.extensionName = "luming"
extension_card.game_modes_whitelist = {"lm_mode"}

--鹿鸣趁火打劫
local lootingSkill = fk.CreateActiveSkill{
  name = "lm_looting_skill",
  target_num = 1,
  mod_target_filter = function(self, to_select, selected, user, card, distance_limited)
    return to_select ~= user.id and not Fk:currentRoom():getPlayerById(to_select):isKongcheng()
  end,
  target_filter = function(self, to_select, _, _, _, _, user)
    return to_select ~= user.id and not Fk:currentRoom():getPlayerById(to_select):isKongcheng()
  end,
  on_effect = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.to)
    if player.dead or target.dead or target:isKongcheng() then return end
    local id = room:askForCardChosen(player, target, "h", self.name)
    target:showCards(id)
    if player.dead or target.dead then return end
    if room:getCardOwner(id) == target and room:getCardArea(id) == Card.PlayerHand then
      if room:askForSkillInvoke(target, self.name, nil, "#lm_looting-give:"..player.id.."::"..effect.card:toLogString()) then
        room:obtainCard(player, id, true, fk.ReasonGive, player.id, "lm_looting")
      else
        room:damage({
          from = player,
          to = target,
          card = effect.card,
          damage = 1,
          skillName = self.name
        })
      end
    else
      room:damage({
        from = player,
        to = target,
        card = effect.card,
        damage = 1,
        skillName = self.name
      })
    end
  end
}
local looting = fk.CreateTrickCard{
  name = "lm_looting",
  skill = lootingSkill,
  is_damage_card = true,
}
extension_card:addCards({
  looting:clone(Card.Spade, 6),
  looting:clone(Card.Club, 6),
  looting:clone(Card.Heart, 6)
})

Fk:loadTranslationTable{
  ["luming_cards"] = "鹿鸣卡组",
}

Fk:loadTranslationTable{
  ["lm_looting"] = "趁火打劫",
  ["lm_looting_skill"] = "趁火打劫",
  [":lm_looting"] = "锦囊牌<br/><b>时机</b>：出牌阶段<br/><b>目标</b>：一名有手牌的其他角色<br/><b>效果</b>：你展示目标角色一张手牌，"..
  "然后令其选择一项：将此牌交给你，或受到你造成的1点伤害。",
  ["#lm_looting-give"] = "趁火打劫：点“确定”将此牌交给 %src ，或点“取消”其对你造成1点伤害",
}

local adaptationSkill = fk.CreateActiveSkill{
  name = "lm_adaptation_skill",
  can_use = Util.FalseFunc
}
local adaptationTriggerSkill = fk.CreateTriggerSkill{
  name = "lm_adaptation_trigger_skill",
  global = true,

  refresh_events = {fk.PreCardUse, fk.PreCardRespond},
  can_refresh = function(self, event, target, player, data)
    return target == player and (data.card.type == Card.TypeBasic or data.card:isCommonTrick())
  end,
  on_refresh = function(self, event, target, player, data)
    if string.find(data.card.name, "adaptation") then return end
    player.room:setPlayerMark(player, "lm_adaptation-turn", data.card.name)
  end,
}
local adaptationFilterSkill = fk.CreateFilterSkill{
  name = "lm_adaptation_filter_skill",
  mute = true,
  global = true,
  card_filter = function(self, card, player)
    return card.name == "lm_adaptation" and player:getMark("lm_adaptation-turn") ~= 0
  end,
  view_as = function(self, card, player)
    return Fk:cloneCard(player:getMark("lm_adaptation-turn"), card.suit, card.number)
  end,
}
local adaptation = fk.CreateTrickCard{
  name = "lm_adaptation",
  skill = adaptationSkill,
}
Fk:addSkill(adaptationTriggerSkill)
Fk:addSkill(adaptationFilterSkill)
extension_card:addCards{
  adaptation:clone(Card.Spade, 10),
  adaptation:clone(Card.Club, 4)
}
Fk:loadTranslationTable{
  ["lm_adaptation"] = "随机应变",
  ["lm_adaptation_filter_skill"] = "随机应变",
  [":lm_adaptation"] = "锦囊牌<br/><b>效果</b>：此牌视为你本回合使用或打出的上一张基本牌或普通锦囊牌（随机应变除外）。",
}

--鹿鸣五谷丰登
local lm_amazing_grace_skill = fk.CreateActiveSkill{
  name = "lm_amazing_grace_skill",
  prompt = "#lm_amazing_grace_skill",
  mod_target_filter = Util.TrueFunc,
  can_use = function(self, player, card)
    return not player:isProhibited(player, card)
  end,
  on_use = function(self, room, cardUseEvent)
    if not cardUseEvent.tos or #TargetGroup:getRealTargets(cardUseEvent.tos) == 0 then
      cardUseEvent.tos = { { cardUseEvent.from } }
    end
  end,
  on_effect = function(self, room, effect)
    local to = room:getPlayerById(effect.to)
    local cards = room:getNCards(5)
    room:moveCards({
      ids = cards,
      toArea = Card.Processing,
      moveReason = fk.ReasonPut,
      skillName = self.name,
      proposer = to.id
    })

    local chosen = room:askForCardChosen(to, to, { card_data = { { "processing_area", cards } } }, self.name, "$ChooseCard")
    -- room:takeAG(player, chosen, room.players)
    room:obtainCard(to, chosen, true, fk.ReasonPrey)
    room:cleanProcessingArea(cards, self.name)
  end
}

local lm_amazing_grace = fk.CreateTrickCard{
  name = "lm_amazing_grace",
  suit = Card.Heart,
  number = 3,
  -- multiple_targets = true,
  skill = lm_amazing_grace_skill,
}
extension_card:addCards({
  lm_amazing_grace,
  lm_amazing_grace:clone(Card.Heart, 4),
})
Fk:loadTranslationTable{
  ["lm_amazing_grace"] = "五谷丰登",
  ["lm_amazing_grace_skill"] = "五谷丰登",
  ["#lm_amazing_grace_skill"] = "亮出牌堆顶五张牌，获得其中一张牌，将其余牌置入弃牌堆",
  [":lm_amazing_grace"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：自己<br /><b>效果</b>：目标亮出牌堆顶五张牌，获得其中一张牌，将其余牌置入弃牌堆。",
}

Fk:addGameMode(require "packages/luming/lm_mode")

-- 这不是LM的一部分，防止循环利用
dofile "packages/luming/lm_qml.lua"

return {
  king,
  idolatry,
  hegemon,
  division,
  extension_card
}